Page({
  data:{
    myArticle:[],
    page:1,
    limit:10,
    isEmpty:false
  },
  onShow(){
    this.getMyArticle()
  },

  async getMyArticle(){
    const {errno,data} = await wx.http.get('/user/myArticle',{
      page:this.data.page,
      limit:this.data.limit
    })
    if(errno !== 0 ) return wx.utils.toast('数据加载失败！')
    this.setData({
      myArticle:data.data,
      isEmpty:data.data.length !==0
    })
  },
  // 删除
  async cancelMyArticle(ev){
    this.setData({myArticle:this.data.myArticle.filter(item => item.id !== ev.mark.id)})  
    await wx.http.get('/user/delArticle',{id:ev.mark.id})
    wx.utils.toast('删除成功!')
  },
  // 编辑
  updateArticle(ev){
    console.log(ev.mark.id);
    wx.reLaunch({
      url: `/pages/release/release?id=${ev.mark.id}&isCheck=0` ,
    })
  }
})